package sys.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Tree implements Serializable {
    private Integer treeid;

    private String treename;

    private Integer pid;

    private String url;

    private String target;
    private List<Tree> trees;					//下级菜单列表

    public Integer getTreeid() {
        return treeid;
    }

    public void setTreeid(Integer treeid) {
        this.treeid = treeid;
    }

    public String getTreename() {
        return treename;
    }

    public void setTreename(String treename) {
        this.treename = treename == null ? null : treename.trim();
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null ? null : url.trim();
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target == null ? null : target.trim();
    }


    public List<Tree> getTrees() {
        return trees;
    }

    public void setTrees(List<Tree> trees) {
        this.trees = trees;
    }

    public boolean isRootId(int rootId) {
        return this.getPid() == rootId;
    }
    public boolean addChild(Object o) {
        Tree tree = (Tree)o;
        if(this.getTreeid()==tree.getPid()){
            if(this.getTrees()==null)
                this.trees=new ArrayList();
            this.trees.add(tree);
            return true;
        }
        return false;
    }
}